home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_13_05
/
allison
/
person3.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-12
|
573b
|
29 lines
LISTING 22 - Adds the assignment operator and copy constructor to
the Person class
//person3.cpp
#include <iostream.h>
#include <string.h>
#include <new.h> // for placement new
#include "person3.h"
Person::Person(const Person & p)
: birth(p.birth)
{
last = clone(p.last);
first = clone(p.first);
ssn = clone(p.ssn);
}
Person & Person::operator=(const Person & p)
{
if (this != &p)
{
this->Person::~Person();
new (this) Person(p);
}
return *this;
}
// (other functions as in Listing 20)